<html
    xmlns="http://www.w3.org/1999/xhtml"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:f="http://java.sun.com/jsf/core"
    xmlns:ui="http://java.sun.com/jsf/facelets"
    xmlns:p="http://primefaces.org/ui">

    <ui:composition template="layout.xhtml">
        <ui:define name="title">
            Cartório
        </ui:define>

        <ui:define name="content">

            <h:form id="pesquisarCartorioForm">
                <p:messages id="pesquisarCartorioMessages" autoUpdate="true" />

                <div class="row">
                    <div class="column2 index_menu">
                        <p:menu>
                            <p:submenu label="Cartório">
                                <p:menuitem url="criarCartorio.xhtml" value="Cadastrar" />
                            </p:submenu>
                        </p:menu>
                    </div>

                    <div class="column10">
                        <f:validateBean disabled="true">
                            <p:fieldset legend="Dados" id="dadosCartorioPanel" >
                                
                                <div class="row">
                                      <div class="column2">
                                          <p:outputLabel value="Razão Social" for="razaoSocialInputText" />
                                      </div>
                                      <div class="column4">
                                          <p:inputText id="razaoSocialInputText" value="#{ managerPesquisarCartorio.cartorioPesquisar.razaoSocial }" />
                                      </div>

                                      <div class="column2">
                                          <p:outputLabel value="Nome Fantasia" for="nomeInputText" />
                                      </div>
                                      <div class="column4">
                                          <p:inputText id="nomeInputText" value="#{ managerPesquisarCartorio.cartorioPesquisar.nomeFantasia }" />
                                      </div>                                    
                                </div>

                                <div class="row">
                                      <div class="column2">
                                          <p:outputLabel value="Titular" for="nomeTitularInputText" />
                                      </div>
                                      <div class="column4">
                                          <p:inputText id="nomeTitularInputText" value="#{ managerPesquisarCartorio.cartorioPesquisar.titular.nome }" />
                                      </div>
                                    <div class="column2">
                                        <p:outputLabel value="Cidade" for="cidadeAutoComplete" />
                                    </div>
                                    <div class="column4">
                                        <p:autoComplete id="cidadeAutoComplete" value="#{ managerPesquisarCartorio.cartorioPesquisar.endereco.cidade }"
                                            forceSelection="true" dropdown="true" var="cidade" itemValue="#{ cidade }" 
                                            itemLabel="#{ cidade.nome }" completeMethod="#{ managerPesquisarCartorio.autocompletarCidade }"
                                            converter="conversorcidade" minQueryLength="3" />
                                    </div>
                                </div>

                            </p:fieldset>
                        </f:validateBean>

                        <div class="command">
                            <p:commandButton
                                id="pesquisarcommandButton" value="Pesquisar" icon="ui-icon-search"
                                styleClass="ui-priority-primary" oncomplete="widthFix();"
                                update="@form" actionListener="#{ managerPesquisarCartorio.pesquisar() }" />
                            <p:commandButton value="Limpar" icon="ui-icon-close" oncomplete="widthFix();"
                                update="@form" actionListener="#{ managerPesquisarCartorio.limpar() }" />
                        </div>

                        <p:dataTable styleClass="column12" id="cartoriosDataTable" var="cartorio"

                                     value="#{ managerPesquisarCartorio.cartorios }"
                                     rows="5" paginator="true" paginatorPosition="bottom" emptyMessage="Nenhum Cartório encontrado">
                            <f:facet name="header" >
                                Cartórios
                            </f:facet>
                            <p:column width="10%" headerText="Opções">
                                <div class="options3">
                                    <p:button
                                        title="Editar" href="criarCartorio.xhtml?cartorioId=#{ cartorio.id }"
                                        icon="ui-icon-pencil"/>
                                    <p:button
                                        title="Visualizar" href="visualizarCartorio.xhtml?cartorioId=#{ cartorio.id }"
                                        icon="ui-icon-search"/>
                                    <p:commandButton title="Excluir" oncomplete="dialogApagar.show()" icon="ui-icon-trash">
                                        <f:setPropertyActionListener target="#{ managerPesquisarCartorio.cartorioDeletar }" value="#{ cartorio }" />
                                    </p:commandButton>
                                </div>
                            </p:column>

                            <p:column headerText="Razão Social" width="30%">
                                <h:outputText value="#{ cartorio.razaoSocial }" />
                            </p:column>
                            <p:column headerText="Nome Fantasia" width="30%">
                                <h:outputText value="#{ cartorio.nomeFantasia }" />
                            </p:column>
                            <p:column headerText="Titular" width="30%">
                                <h:outputText value="#{ cartorio.titular.nome }" />
                            </p:column>                            

                        </p:dataTable>

                    </div>
                </div>
            </h:form>

        </ui:define>
    </ui:composition>

</html>
